package com.zoe.onelink.enhancer.autoconfigure;

import com.zoe.onelink.enhancer.init.ApplicationInitializer;
import com.zoe.onelink.enhancer.init.ApplicationInitializerInvoker;
import com.zoe.onelink.enhancer.monitor.ApplicationInfoPrinter;
import com.zoe.onelink.enhancer.scanner.ClassScanner;
import com.zoe.onelink.enhancer.scanner.ClassesScannerInvoker;
import org.springframework.beans.factory.ObjectProvider;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.util.List;

/**
 * <p>标题: </p>
 * <p>描述: </p>
 * <p>版权: Copyright (c) 2022</p>
 * <p>公司: 智业软件股份有限公司</p>
 *
 * @version: 1.0
 * @author: ruansheng
 * @date: 2022-12-14
 */
@Configuration(proxyBeanMethods = false)
public class OnelinkEnhancerAutoConfiguration {

    @Bean
    public ApplicationInitializerInvoker applicationInitializerInvoker(ApplicationContext applicationContext,
                                                                       ObjectProvider<List<ApplicationInitializer>> applicationInitializerProvider) {
        return new ApplicationInitializerInvoker(applicationContext, applicationInitializerProvider.getIfAvailable());
    }

    @Bean
    public ClassesScannerInvoker classesScannerInvoker(ObjectProvider<List<ClassScanner>> classScannerListProvider) {
        return new ClassesScannerInvoker(classScannerListProvider.getIfAvailable());
    }

    @Bean
    public ApplicationInfoPrinter applicationInfoPrinter() {
        return new ApplicationInfoPrinter();
    }

}
